package com.ruoyi.system.outto.thread;

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.Constant;
import com.ruoyi.common.exception.GlobalException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.V2.goodInfo.mapper.GoodsInfoImgMapper;
import com.ruoyi.system.V2.inter.mapper.*;
import com.ruoyi.system.V2.inter.service.IInterRecService;
import com.ruoyi.system.model.domain.*;
import com.ruoyi.system.model.dto.GoodsInfoAndAttrValueDto;
import com.ruoyi.system.outrecV2.mapper.OutRecV2Mapper;
import com.ruoyi.system.outto.core.LCConstant;
import com.ruoyi.system.outto.game.CommonApi;
import com.ruoyi.system.outto.goods.*;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author lz
 * @version 1.0
 * @date 2022/6/18 9:04
 */
@Component
public class StartInter {


    @Resource
    private OutRecMapper outRecMapper;
    @Resource
    private OutRecV2Mapper outRecV2Mapper;
    @Resource
    private ArtRecMapper artRecMapper;
    @Resource
    private ApiTaskPoolMapper apiTaskPoolMapper;
    @Autowired
    private CommonApi commonApi;
    @Resource
    private ApiReqCopyMapper apiReqCopyMapper;
    @Resource
    private GoodsInfoImgMapper goodsInfoImgMapper;
    @Resource
    private SalePartnerMapper salePartnerMapper;
    @Autowired
    private IInterRecService interRecService;
    @Autowired
    private AdapterApi adapterApi;
    @Autowired
    private IPanZhiScriptService iPanZhiScriptService;
    @Autowired
    private IKeJinShouApi iKeJinShouApi;
    @Autowired
    private INew7881Api iNew7881Api;
    @Autowired
    private NEWXIZAIAPI newxizaiapi;
    @Autowired
    private NEWIMMAPI newimmapi;
    @Autowired
    private TAOHAOHAOAPI taohaohaoapi;
    @Autowired
    private NEWCYAPI newcyapi;
    @Autowired
    private NEWZHGAPI newzhgapi;
    @Autowired
    private NEWIPXAPI newipxapi;
    @Autowired
    private NEWQMLAPI newqmlapi;
    @Autowired
    private IMTaoShouYouAPI imTaoShouYouAPI;
    @Autowired
    private YSYAPI ysyapi;
    @Autowired
    private NEWZHWAPI newzhwapi;
    @Autowired
    private NEWENYOUAPI newenyouapi;
    @Autowired
    private NEWKANGEHAOAPI newkangehaoapi;
    @Autowired
    private MIKeJinShouAPI miKeJinShouAPI;
    @Autowired
    private NEWMAIGEHAOAPI newmaigehaoapi;
    @Autowired
    private NEWXHAPI newxhapi;
    @Autowired
    private NEWCYTAPI newcytapi;
    @Autowired
    private NEWCRAPI newcrapi;
    @Autowired
    private NEWLXYAPI newlxyapi;
    @Autowired
    private MONIMIMAAPI monimimaapi;
    @Autowired
    private NEWFEIHENGAPI newfeihengapi;
    @Autowired
    private DAISHOUWANAPI daishouwanapi;
    @Autowired
    private QIANPangXieApi qianPangXieApi;
    @Autowired
    private NEWIPANZHIAPI newipanzhiapi;
    @Autowired
    private NEWTHGAPI newthgapi;
    @Autowired
    private IHuanHaoBaApi iHuanHaoBaApi;
    @Autowired
    private DGGAPI dggapi;
    @Autowired
    private INEWPangXieScriptService inewPangXieScriptService;
    @Autowired
    private NEWJUHAOYOUAPI newjuhaoyouapi;
    @Autowired
    private HEITAOAPI heitaoapi;
    @Autowired
    private MONIYOUXIGEAPI moniyouxigeapi;
    @Autowired
    private NEWSHENXIANAPI newshenxianapi;
    @Autowired
    private TANXINZHUAPI tanxinzhuapi;
    @Autowired
    private RENYIAPI renyiapi;
    @Autowired
    private NEWJYYAPI newjyyapi;
    @Autowired
    private HOUPANGXIEApi houpangxieApi;
    @Autowired
    private IJiaoYiMaoAPI iJiaoYiMaoAPI;
    @Autowired
    private OLDJiaoYiMaoAPI oldJiaoYiMaoAPI;
    @Autowired
    private TaoShouYouAPI taoShouYouAPI;
    @Autowired
    private NEWDDDSAPI newdddsapi;
    @Autowired
    private NEW5173API new5173API;
    @Autowired
    private MAIHAOXIONGAPI maihaoxiongapi;
    @Autowired
    private YUDUHULIANAPI yuduhulianapi;
    @Autowired
    private NEWTWMAPI newtwmapi;
    @Autowired
    private KKZHWApi kkzhwApi;
    @Autowired
    private MUMUDAISHOUAPI mumudaishouapi;
    @Autowired
    private BAIZEAPI baizeapi;
    @Autowired
    private MONITAOHAOHAOAPI monitaohaohaoapi;
    @Autowired
    private YUELIANGDAISHOUAPI yueliangdaishouapi;
    @Autowired
    private IMaiHaoWanApi iMaiHaoWanApi;
    @Autowired
    private TAOHAOYAAPI taohaoyaapi;
    @Autowired
    private MONI7881Api moni7881Api;
    @Autowired
    private NEWZUYOULEAPI newzuyouleapi;
    @Autowired
    private YISHOUYOUAPI yishouyouapi;
    @Autowired
    private NEWLXYCAPI newlxycapi;
    @Autowired
    private NIGUANGAPI niguangapi;
    @Autowired
    private DD373API dd373API;
    @Autowired
    private MONIXIZAIApi monixizaiApi;
    @Autowired
    private NEWSHIQIAPI newshiqiapi;

    String operType = "";

    /**
     * 状态码
     */
    public static final String CODE_TAG = "code";

    /**
     * 返回内容
     */
    public static final String MSG_TAG = "msg";
    public static final String OUTDI = "outId";


    @Transactional
    public void start(GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto, String type, int delType, Long taskId,
                      List<Long> saleNames) {

        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.put(CODE_TAG, 200);
        ajaxResult.put(MSG_TAG, "操作成功");
        ajaxResult.put(OUTDI, null);


        for (Long saleId : saleNames) {
            SalePartner salePartner = salePartnerMapper.selectSalePartnerById(saleId);
            ArtRec artRecreq = new ArtRec();
            artRecreq.setConfig(saleId);
            artRecreq.setAccountId(goodsInfoAndAttrValueDto.getId());
            List<ArtRec> artRecs = artRecMapper.selectArtRecList(artRecreq);
            if (CollectionUtils.isNotEmpty(artRecs) && StringUtils.isNotEmpty(artRecs.get(0).getOutid())) {
                goodsInfoAndAttrValueDto.setOutId(artRecs.get(0).getOutid());
            } else {
                goodsInfoAndAttrValueDto.setOutId(goodsInfoAndAttrValueDto.getThirdId());
            }
            //加价
            BigDecimal bigDecimal = commonApi.addPrice(goodsInfoAndAttrValueDto.getPrice(), salePartner.getSeleep());
            commonApi.setPrice(bigDecimal, goodsInfoAndAttrValueDto.getId(), salePartner);
            goodsInfoAndAttrValueDto.setPrice(bigDecimal);


            if (salePartner.getIs_random() == 1) {
                GoodsInfoImg goodsInfoImg = new GoodsInfoImg();
                goodsInfoImg.setGoodsId(goodsInfoAndAttrValueDto.getId());
                goodsInfoImg.setType("1");
                List<GoodsInfoImg> goodsInfoImgs = goodsInfoImgMapper.selectGoodsInfoImgList(goodsInfoImg);
                if (goodsInfoImgs.size() > 40) {
                    goodsInfoImgs = goodsInfoImgs.subList(0, 39);
                }
//                if(CollectionUtils.isNotEmpty(goodsInfoImgs)) {
//                    if (goodsInfoImgs.size() > 2) {
//                        goodsInfoAndAttrValueDto.setTitleImg(goodsInfoImgs.get(3).getImgUrl());
//                    } else {
//                        goodsInfoAndAttrValueDto.setTitleImg(goodsInfoImgs.get(0).getImgUrl());
//                    }
//                }
                //打乱详情图顺序
                List<GoodsInfoImg> collect = goodsInfoImgs.stream().sorted((a, b) -> Math.random() > 0.5 ? 1 : -1).collect(Collectors.toList());

                List<Map<String, Object>> imgMaps = new ArrayList<>();
                for (GoodsInfoImg goodsImg : collect) {
                    Map<String, Object> imgMap = new HashMap<>();
                    if (!StringUtils.isNull(goodsImg.getFileName()) && !StringUtils.isNull(goodsImg.getImgUrl())) {
                        imgMap.put("name", goodsImg.getFileName());
                        imgMap.put("url", goodsImg.getImgUrl());
                        imgMaps.add(imgMap);
                    }
                }
                if (!org.springframework.util.CollectionUtils.isEmpty(imgMaps)) {
                    goodsInfoAndAttrValueDto.setUrlArr(imgMaps);
                }
//                goodsInfoAndAttrValueDto.setTitle(goodsInfoAndAttrValueDto.getAccountNumber()+"-"+goodsInfoAndAttrValueDto.getTitle());
//                goodsInfoAndAttrValueDto.setDes(goodsInfoAndAttrValueDto.getAccountNumber()+"-"+goodsInfoAndAttrValueDto.getDes());
                goodsInfoAndAttrValueDto.setAccountNumber(createQQAccount());
                if (StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getCarrierName())) {
                    if (goodsInfoAndAttrValueDto.getCarrierName().equals("微信")) {
                        goodsInfoAndAttrValueDto.setAccountNumber("vx" + createQQAccount());
                    }
                }
            } else {
                //标题
                if (!salePartner.getSaleName().equals("POXIAO") && !salePartner.getSaleName().equals("JYM")
                        && !salePartner.getSaleName().equals("RENYI")
                        && !salePartner.getSaleName().equals("NEWZUYOULE")
                        && !salePartner.getSaleName().equals("PZZ_TIANKONG")) {
//                goodsInfoAndAttrValueDto.setTitle(goodsInfoAndAttrValueDto.getId() + "_" + goodsInfoAndAttrValueDto.getTitle());
                    goodsInfoAndAttrValueDto.setDes(goodsInfoAndAttrValueDto.getId() + "_" + goodsInfoAndAttrValueDto.getDes());
                }
            }


            if (type.equals(Constant.add)) {
                this.operType = "2";
                try {
                    if (Objects.isNull(salePartner)) {
                        throw new GlobalException("salePartner为空saleId=:" + saleId);
                    }
                    if (salePartner.getSaleName().contains(LCConstant.saleNameJIAOYIMAO)) {
                        ajaxResult = iJiaoYiMaoAPI.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameJYM)) {
                        Thread.sleep(2000);
                        ajaxResult = oldJiaoYiMaoAPI.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNamePANZHI)) {
                        ajaxResult = iPanZhiScriptService.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameKJS)) {
                        ajaxResult = iKeJinShouApi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleName7881)) {
                        ajaxResult = iNew7881Api.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameXIZAI)) {
                        ajaxResult = newxizaiapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameJYY)) {
                        ajaxResult = newjyyapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameTAOHH)) {
                        ajaxResult = taohaohaoapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameMMM)) {
                        ajaxResult = newimmapi.addAndEditGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameFEIHENG)) {
                        ajaxResult = newfeihengapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameTHW)) {
                        ajaxResult = daishouwanapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameHHB)) {
                        ajaxResult = iHuanHaoBaApi.addAndEditAndDelGame(goodsInfoAndAttrValueDto, "add", salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameQIANPANGXIE)) {
                        ajaxResult = qianPangXieApi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNamePZZ)) {
                        ajaxResult = newipanzhiapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameTHG)) {
                        ajaxResult = newthgapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameCHUANGYOU)) {
                        ajaxResult = newcyapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameZHG)) {
                        ajaxResult = newzhgapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNamePOXIAO)) {
                        ajaxResult = newipxapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameQML)) {
                        ajaxResult = newqmlapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameQIANTSQ)) {
                        ajaxResult = imTaoShouYouAPI.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameYSY)) {
                        ajaxResult = ysyapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameZHW)) {
                        ajaxResult = newzhwapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameENYOU)) {
                        ajaxResult = newenyouapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameKGH)) {
                        ajaxResult = newkangehaoapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameMKEJINSHOU)) {
                        ajaxResult = miKeJinShouAPI.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameMGH)) {
                        ajaxResult = newmaigehaoapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameXINGHE)) {
                        ajaxResult = newxhapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameCYT)) {
                        ajaxResult = newcytapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameCR)) {
                        ajaxResult = newcrapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameLXY)) {
                        ajaxResult = newlxyapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameMONIMIMA)) {
                        ajaxResult = monimimaapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameTAOSHOUYOU)) {
                        ajaxResult = taoShouYouAPI.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameDDDS)) {
                        ajaxResult = newdddsapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleName5173)) {
                        ajaxResult = new5173API.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameMAIHAOXIONG)) {
                        ajaxResult = maihaoxiongapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameYDHULIAN)) {
                        ajaxResult = yuduhulianapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameTWM)) {
                        ajaxResult = newtwmapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameDGG)) {
                        ajaxResult = dggapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameNEWMONIPANGXIE)) {
                        ajaxResult = inewPangXieScriptService.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameJUHAOYOU)) {
                        ajaxResult = newjuhaoyouapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameHEITAO)) {
                        ajaxResult = heitaoapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameMONIYOUXIGE)) {
                        ajaxResult = moniyouxigeapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameSHENXIAN) && goodsInfoAndAttrValueDto.getSaleState() == 1) {
                        ajaxResult = newshenxianapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameTANXINZHU)) {
                        ajaxResult = tanxinzhuapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameRENYI)) {
                        ajaxResult = renyiapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameKANKAN)) {
                        ajaxResult = kkzhwApi.addGame(goodsInfoAndAttrValueDto, salePartner, true);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameMUMUDAISHOU)) {
                        ajaxResult = mumudaishouapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameBAIZE)) {
                        ajaxResult = baizeapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameMONITAOHAOHAO)) {
                        ajaxResult = monitaohaohaoapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameYUELIANGDS)) {
                        ajaxResult = yueliangdaishouapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameMHW)) {
                        ajaxResult = iMaiHaoWanApi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameTAOHAOYA)) {
                        ajaxResult = taohaoyaapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameMONI788ONE)) {
                        ajaxResult = moni7881Api.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameNEWZUYOULE)) {
                        ajaxResult = newzuyouleapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameYISHOUYOU)) {
                        ajaxResult = yishouyouapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameYUNCANG)) {
                        ajaxResult = newlxycapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameNIGUANG)) {
                        ajaxResult = niguangapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameDD373)) {
                        ajaxResult = dd373API.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameMONIXIZAI)) {
                        ajaxResult = monixizaiApi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameSHIQI)) {
                        ajaxResult = newshiqiapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    }

//                    else if (salePartner.getSaleName().contains(LCConstant.saleNameCHUANGYOU)) {
//                        ajaxResult = newcyapi.addGame(goodsInfoAndAttrValueDto, salePartner);
//                    }

//                    else if (salePartner.getSaleName().contains(LCConstant.saleNameDGG)) {
//                        ajaxResult = dggapi.addGame(goodsInfoAndAttrValueDto, salePartner);
//                    }

                    else {
                        ajaxResult = adapterApi.addGame(goodsInfoAndAttrValueDto, salePartner);
                    }
                    {
                        String outId = JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data"))).getString("outId");
                        if (StringUtils.isNotEmpty(outId)) {
                            ArtRec artRecreq2 = new ArtRec();
                            artRecreq2.setConfig(salePartner.getId());
                            artRecreq2.setAccountId(goodsInfoAndAttrValueDto.getId());
                            List<ArtRec> artRecs2 = artRecMapper.selectArtRecList(artRecreq2);
                            if (CollectionUtils.isNotEmpty(artRecs2)) {
                                artRecs2.get(0).setOutid(outId);
                                artRecMapper.updateArtRec(artRecs2.get(0));
                            } else {
                                artRecreq2.setAccountId(goodsInfoAndAttrValueDto.getId());
                                artRecreq2.setCreateId(goodsInfoAndAttrValueDto.getCreateId());
                                artRecreq2.setType(LCConstant.interAdd);
                                artRecreq2.setConfig(salePartner.getId());
                                artRecreq2.setSaleCode(salePartner.getSaleName());
                                artRecreq2.setOutid(outId);
                                artRecMapper.insertArtRec(artRecreq2);
                            }
                        }
                    }
                    getOutRecAndInterRec(ajaxResult, salePartner.getSaleName(), salePartner, goodsInfoAndAttrValueDto, taskId);
                } catch (Exception e) {
                    e.printStackTrace();
                    ajaxResult.put(CODE_TAG, 500);
                    ajaxResult.put(MSG_TAG, e.getMessage());
                    getOutRecAndInterRec(ajaxResult, salePartner.getSaleName(), salePartner, goodsInfoAndAttrValueDto, taskId);
                }
            } else if (type.equals(Constant.edit)) {
                if (goodsInfoAndAttrValueDto.getSaleState() != 1) {
                    apiTaskPoolMapper.deleteApiTaskPoolByConfigAndId(goodsInfoAndAttrValueDto.getId(), salePartner.getId(), LCConstant.interEdit);
                } else {
                    this.operType = "1";
                    if (true) {
                        if (Objects.isNull(salePartner)) {
                            throw new GlobalException("salePartner为空saleId=:" + saleId);
                        }
                        try {
                            if (salePartner.getSaleName().contains(LCConstant.saleNameJIAOYIMAO)) {
                                ajaxResult = iJiaoYiMaoAPI.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameJYM)) {
                                Thread.sleep(2000);
                                ajaxResult = oldJiaoYiMaoAPI.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNamePANZHI)) {
                                Thread.sleep(1000);
                                ajaxResult = iPanZhiScriptService.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameKJS)) {
                                ajaxResult = iKeJinShouApi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleName7881)) {
                                Thread.sleep(500);
                                ajaxResult = iNew7881Api.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameXIZAI)) {
                                ajaxResult = newxizaiapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameJYY)) {
                                ajaxResult = newjyyapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameTAOHH)) {
                                ajaxResult = taohaohaoapi.addGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameMMM)) {
                                ajaxResult = newimmapi.addAndEditGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameFEIHENG)) {
                                ajaxResult = newfeihengapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameTHW)) {
                                ajaxResult = daishouwanapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameHHB)) {
                                ajaxResult = iHuanHaoBaApi.addAndEditAndDelGame(goodsInfoAndAttrValueDto, "mod", salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameQIANPANGXIE)) {
                                ajaxResult = qianPangXieApi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNamePZZ)) {
                                ajaxResult = newipanzhiapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameTHG)) {
                                ajaxResult = newthgapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameCHUANGYOU)) {
                                ajaxResult = newcyapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameZHG)) {
                                ajaxResult = newzhgapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNamePOXIAO)) {
                                ajaxResult = newipxapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameQML)) {
                                ajaxResult = newqmlapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameQIANTSQ)) {
                                ajaxResult = imTaoShouYouAPI.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameYSY)) {
                                ajaxResult = ysyapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameZHW)) {
                                ajaxResult = newzhwapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameENYOU)) {
                                ajaxResult = newenyouapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameKGH)) {
                                ajaxResult = newkangehaoapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameMKEJINSHOU)) {
                                ajaxResult = miKeJinShouAPI.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameMGH)) {
                                ajaxResult = newmaigehaoapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameXINGHE)) {
                                ajaxResult = newxhapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameCYT)) {
                                ajaxResult = newcytapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameCR)) {
                                ajaxResult = newcrapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameLXY)) {
                                ajaxResult = newlxyapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameMONIMIMA)) {
                                ajaxResult = monimimaapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameTAOSHOUYOU)) {
                                ajaxResult = taoShouYouAPI.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameDDDS)) {
                                ajaxResult = newdddsapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleName5173)) {
                                ajaxResult = new5173API.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameMAIHAOXIONG)) {
                                ajaxResult = maihaoxiongapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameYDHULIAN)) {
                                ajaxResult = yuduhulianapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameTWM)) {
                                ajaxResult = newtwmapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameDGG)) {
                                ajaxResult = dggapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameNEWMONIPANGXIE) || salePartner.getSaleName().contains(LCConstant.saleNameHOUPANGXIE)) {
                                ajaxResult = inewPangXieScriptService.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameJUHAOYOU)) {
                                ajaxResult = newjuhaoyouapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameHEITAO)) {
                                ajaxResult = heitaoapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameMONIYOUXIGE)) {
                                ajaxResult = moniyouxigeapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameSHENXIAN)) {
                                ajaxResult = newshenxianapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameTANXINZHU)) {
                                ajaxResult = tanxinzhuapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameRENYI)) {
                                ajaxResult = renyiapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameKANKAN)) {
                                ajaxResult = kkzhwApi.editGame(goodsInfoAndAttrValueDto, salePartner, false);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameMUMUDAISHOU)) {
                                ajaxResult = mumudaishouapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameBAIZE)) {
                                ajaxResult = baizeapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameMONITAOHAOHAO)) {
                                ajaxResult = monitaohaohaoapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameYUELIANGDS)) {
                                ajaxResult = yueliangdaishouapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameMHW)) {
                                ajaxResult = iMaiHaoWanApi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameTAOHAOYA)) {
                                ajaxResult = taohaoyaapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameMONI788ONE)) {
                                Thread.sleep(500);
                                ajaxResult = moni7881Api.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameNEWZUYOULE)) {
                                ajaxResult = newzuyouleapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameYISHOUYOU)) {
                                ajaxResult = yishouyouapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameYUNCANG)) {
                                ajaxResult = newlxycapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameNIGUANG)) {
                                ajaxResult = niguangapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameDD373)) {
                                ajaxResult = dd373API.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameMONIXIZAI)) {
                                ajaxResult = monixizaiApi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            } else if (salePartner.getSaleName().contains(LCConstant.saleNameSHIQI)) {
                                ajaxResult = newshiqiapi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            }

//                        else if (salePartner.getSaleName().contains(LCConstant.saleNameCHUANGYOU)) {
//                            ajaxResult = newcyapi.editGame(goodsInfoAndAttrValueDto, salePartner);
//                        }

//                        else if (salePartner.getSaleName().contains(LCConstant.saleNameDGG)) {
//                            ajaxResult = dggapi.editGame(goodsInfoAndAttrValueDto, salePartner);
//                        }

                            else {
                                ajaxResult = adapterApi.editGame(goodsInfoAndAttrValueDto, salePartner);
                            }
                            insertOutRec(ajaxResult, goodsInfoAndAttrValueDto, LCConstant.interEdit, salePartner, taskId);
                        } catch (Exception e) {
                            e.printStackTrace();
                            ajaxResult.put(CODE_TAG, 500);
                            ajaxResult.put(MSG_TAG, e.getMessage());
                            insertOutRec(ajaxResult, goodsInfoAndAttrValueDto, LCConstant.interEdit, salePartner, taskId);
                        }
                    }
                }
            } else if (type.equals(Constant.del)) {
                this.operType = "1";
                try {
                    if (Objects.isNull(salePartner)) {
                        throw new GlobalException("salePartner为空saleId=:" + saleId);
                    }
                    if (salePartner.getSaleName().contains(LCConstant.saleNameJIAOYIMAO)) {
                        ajaxResult = iJiaoYiMaoAPI.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameJYM)) {
                        Thread.sleep(2000);
                        ajaxResult = oldJiaoYiMaoAPI.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNamePANZHI)) {
                        Thread.sleep(1000);
                        ajaxResult = iPanZhiScriptService.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameKJS)) {
                        ajaxResult = iKeJinShouApi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleName7881)) {
                        ajaxResult = iNew7881Api.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameXIZAI)) {
                        ajaxResult = newxizaiapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameJYY)) {
                        ajaxResult = newjyyapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameTAOHH)) {
                        ajaxResult = taohaohaoapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameMMM)) {
                        ajaxResult = newimmapi.delGame(goodsInfoAndAttrValueDto, 2, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameFEIHENG)) {
                        ajaxResult = newfeihengapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameTHW)) {
                        ajaxResult = daishouwanapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameHHB)) {
                        ajaxResult = iHuanHaoBaApi.addAndEditAndDelGame(goodsInfoAndAttrValueDto, "del", salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameQIANPANGXIE)) {
                        ajaxResult = qianPangXieApi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNamePZZ)) {
                        ajaxResult = newipanzhiapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameTHG)) {
                        ajaxResult = newthgapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameCHUANGYOU)) {
                        ajaxResult = newcyapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameZHG)) {
                        ajaxResult = newzhgapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNamePOXIAO)) {
                        ajaxResult = newipxapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameQML)) {
                        ajaxResult = newqmlapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameQIANTSQ)) {
                        ajaxResult = imTaoShouYouAPI.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameYSY)) {
                        ajaxResult = ysyapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameZHW)) {
                        ajaxResult = newzhwapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameENYOU)) {
                        ajaxResult = newenyouapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameKGH)) {
                        ajaxResult = newkangehaoapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameMKEJINSHOU)) {
                        ajaxResult = miKeJinShouAPI.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameMGH)) {
                        ajaxResult = newmaigehaoapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameXINGHE)) {
                        ajaxResult = newxhapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameCYT)) {
                        ajaxResult = newcytapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameCR)) {
                        ajaxResult = newcrapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameLXY)) {
                        ajaxResult = newlxyapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameMONIMIMA)) {
                        ajaxResult = monimimaapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameTAOSHOUYOU)) {
                        ajaxResult = taoShouYouAPI.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameDDDS)) {
                        ajaxResult = newdddsapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleName5173)) {
                        ajaxResult = new5173API.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameMAIHAOXIONG)) {
                        ajaxResult = maihaoxiongapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameYDHULIAN)) {
                        ajaxResult = yuduhulianapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameTWM)) {
                        ajaxResult = newtwmapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameDGG)) {
                        ajaxResult = dggapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameNEWMONIPANGXIE) || salePartner.getSaleName().contains(LCConstant.saleNameHOUPANGXIE)) {
                        ajaxResult = inewPangXieScriptService.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameJUHAOYOU)) {
                        ajaxResult = newjuhaoyouapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameHEITAO)) {
                        ajaxResult = heitaoapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameMONIYOUXIGE)) {
                        ajaxResult = moniyouxigeapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameSHENXIAN)) {
                        ajaxResult = newshenxianapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameTANXINZHU)) {
                        ajaxResult = tanxinzhuapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameRENYI)) {
                        ajaxResult = renyiapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameKANKAN)) {
                        ajaxResult = kkzhwApi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameMUMUDAISHOU)) {
                        ajaxResult = mumudaishouapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameBAIZE)) {
                        ajaxResult = baizeapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameMONITAOHAOHAO)) {
                        ajaxResult = monitaohaohaoapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameYUELIANGDS)) {
                        ajaxResult = yueliangdaishouapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameMHW)) {
                        ajaxResult = iMaiHaoWanApi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameTAOHAOYA)) {
                        ajaxResult = taohaoyaapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameMONI788ONE)) {
                        Thread.sleep(500);
                        ajaxResult = moni7881Api.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameNEWZUYOULE)) {
                        ajaxResult = newzuyouleapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameYISHOUYOU)) {
                        ajaxResult = yishouyouapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameYUNCANG)) {
                        ajaxResult = newlxycapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameNIGUANG)) {
                        ajaxResult = niguangapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameDD373)) {
                        ajaxResult = dd373API.delGame(goodsInfoAndAttrValueDto, salePartner, "2");
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameNIGUANG)) {
                        ajaxResult = niguangapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameMONIXIZAI)) {
                        ajaxResult = monixizaiApi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    } else if (salePartner.getSaleName().contains(LCConstant.saleNameSHIQI)) {
                        ajaxResult = newshiqiapi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    }

//                    else if (salePartner.getSaleName().contains(LCConstant.saleNameCHUANGYOU)) {
//                        ajaxResult = newcyapi.delGame(goodsInfoAndAttrValueDto, salePartner);
//                    }

//                    else if (salePartner.getSaleName().contains(LCConstant.saleNameDGG)) {
//                        ajaxResult = dggapi.delGame(goodsInfoAndAttrValueDto, salePartner);
//                    }

                    else {
                        ajaxResult = adapterApi.delGame(goodsInfoAndAttrValueDto, salePartner);
                    }
//                    Thread.sleep(1000);
                    delInterRec(goodsInfoAndAttrValueDto.getId(), salePartner.getSaleName());

                    insertOutRec(ajaxResult, goodsInfoAndAttrValueDto, LCConstant.interDel, salePartner, taskId);

                } catch (Exception e) {
                    e.printStackTrace();
                    ajaxResult.put(CODE_TAG, 500);
                    ajaxResult.put(MSG_TAG, e.getMessage());
                    insertOutRec(ajaxResult, goodsInfoAndAttrValueDto, LCConstant.interDel, salePartner, taskId);
                }
            }
        }
    }

    private void delInterRec(Long id, String saleName) {
        InterRec interRec = new InterRec();
        interRec.setAccountId(id);
        interRec.setSaleCode(saleName);
        int i = interRecService.deleteInterRec(id, saleName);
    }

    @Transactional
    public void getOutRecAndInterRec(AjaxResult ajaxResult, String saleNameLCC, SalePartner salePartner,
                                     GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto, Long taskId) {
        insertOutRec(ajaxResult, goodsInfoAndAttrValueDto, LCConstant.interAdd, salePartner, taskId);
        interRecService.save(saleNameLCC, goodsInfoAndAttrValueDto.getId(), goodsInfoAndAttrValueDto.getCreateId());
    }

    /**
     * 封装入参记录（保存推送记录）
     *
     * @param ajaxResults
     * @param interType
     * @return
     */
    @Transactional
    public void insertOutRec(AjaxResult ajaxResults, GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto,
                             String interType, SalePartner salePartner, Long taskId) {
//        ApiTaskPool apiTaskPool = new ApiTaskPool();
//        if (Objects.nonNull(taskId)) {
//            apiTaskPool = apiTaskPoolMapper.selectApiTaskPoolById(taskId);
//            if (Objects.nonNull(apiTaskPool)) {
//                ApiReqCopy apiReqCopy = new ApiReqCopy();
//                BeanUtils.copyProperties(apiTaskPool, apiReqCopy);
//                apiTaskPoolMapper.deleteApiTaskPoolById(taskId);
//            }
//        }

        if (LCConstant.interEdit.equals(interType)) {

            apiTaskPoolMapper.deleteApiTaskPoolByConfigAndId(goodsInfoAndAttrValueDto.getId(), salePartner.getId(), LCConstant.interEdit);

        }
        if (LCConstant.interDel.equals(interType)) {
            artRecMapper.deleteArtRecCode(goodsInfoAndAttrValueDto.getId(), salePartner.getId());
        }

        OutRec outRec = new OutRec();
        outRec.setAccountid(goodsInfoAndAttrValueDto.getId());
        outRec.setType(goodsInfoAndAttrValueDto.getGameName());
        outRec.setSupllyid(goodsInfoAndAttrValueDto.getCreateId());
        Long userId = goodsInfoAndAttrValueDto.getCreateId();
        outRec.setCreateId(userId);
//        if (Objects.isNull(userId) || 0l == userId) {
//            if (Objects.nonNull(apiTaskPool)) {
//                outRec.setCreateId(apiTaskPool.getCreateId());
//            } else {
//                outRec.setCreateId(1l);
//            }
//        } else {
//            outRec.setCreateId(userId);
//        }

        Long accountId = goodsInfoAndAttrValueDto.getId();
        if (!Objects.isNull(salePartner)) {
            outRec.setSaleId(salePartner.getName());
            outRec.setSalecode(salePartner.getSaleName());
            /**
             * 格式：
             * 成功条数：100
             * 失败条数：200
             * 失败原因：
             * id:errInfo
             */
            StringBuffer result = new StringBuffer();
            int success = 0;
            int error = 0;
            StringBuffer errInfo = new StringBuffer();
            Integer code = MapUtils.getInteger(ajaxResults, CODE_TAG);
            String msg = "";
            String req = "";
            String res = "";
            if (Objects.equals(HttpStatus.SUCCESS, code)) {
                Object data = MapUtils.getObject(ajaxResults, "data");
                String s = JSONObject.toJSONString(data);
                JSONObject jsonObject = JSONObject.parseObject(s);
                if (StringUtils.isNotEmpty(s) && StringUtils.isNotEmpty(jsonObject)) {
                    req = jsonObject.getString("req");
                    res = jsonObject.getString("res");
                    outRec.setReq(req);
                    outRec.setRes(res);
                    if (Objects.equals(500, jsonObject.getInteger("code"))) {
                        error++;
                        try {
                            msg = MapUtils.getString(JSONObject.parseObject(res), MSG_TAG);
                            if (StringUtils.isEmpty(msg)) {
                                msg = MapUtils.getString(jsonObject, "res");
                            }
                        } catch (Exception e) {
                            msg = res;
                        }
                        errInfo.append(msg + "\n");
                    } else {
                        success++;
                        //成功
                        if (LCConstant.interAdd.equals(interType)) {
                            ArtRec artRec = new ArtRec();
                            artRec.setAccountId(accountId);
                            artRec.setCreateId(goodsInfoAndAttrValueDto.getCreateId());
                            artRec.setType(interType);
                            artRec.setConfig(salePartner.getId());
                            artRec.setSaleCode(salePartner.getSaleName());
                        }
                    }
                }
            } else {
                error++;
                msg = MapUtils.getString(ajaxResults, MSG_TAG);
                errInfo.append(accountId + ":" + msg + "\n");
                outRec.setRes(msg);
            }
            result.append("成功：" + success +
                    "条,失败：" + error + "条,失败原因：" + errInfo + ",id为" + accountId);
            outRec.setResult(result.toString());
            outRec.setSuccessCount(success);
            outRec.setErrCount(error);
            outRec.setInter(interType);
            outRec.setCreateTime(DateUtils.getNowDate());
            outRecMapper.insertOutRec(outRec);


            if (success == 0 && error == 1) {
                outRecV2Mapper.insertOutRec(outRec);
            }
        }
    }

    public static String createQQAccount() {
        int num = 8;
        String[] vec = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
        num = num <= 0 ? 1 : num;
        StringBuffer str = new StringBuffer(10);
        for (int i = 0; i < num; i++) {
            int r1 = Long.valueOf(Math.round(Math.random() * (vec.length - 1))).intValue();
            str.append(vec[r1]);
        }
        return str.toString();
    }
}
